 <!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width,initial-scale=1,minimum-scale=1,maximum-scale=1,user-scalable=no" />
    <title>学生列表</title>
    <link rel="stylesheet" type="text/css" href="../../static/admin/layui_new/css/layui.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/admin.css"/>
    <link rel="stylesheet" type="text/css" href="../../static/admin/css/my.css"/>
</head>
<body>
<div class="wrap-container welcome-container">
    <div class="row">

        <div class="welcome-left-container persion-top">
            <div class="user-list-table">
<!--                <div class="demoTable">-->
<!--                    搜索ID：-->
<!--                    <div class="layui-inline">-->
<!--                        <input class="layui-input" name="id" id="demoReload" autocomplete="off">-->
<!--                    </div>-->
<!--                    <button class="layui-btn" data-type="reload">搜索</button>-->
<!--                </div>-->
                <table class="layui-hide" id="LAY_table_user" lay-filter="user"></table>
            </div>
		</div>
    </div>
</div>
<div class="wrap-container welcome-container">
    <div class="row">
        <div style="width:300px;margin:auto;left: 0;right: 0; padding:20px 0;position: fixed;bottom: 0px;justify-content: center;flex-direction: column; ">
            <a target="_blank" href="http://www.beian.gov.cn/portal/registerSystemInfo?recordcode=42018502004474" style="display:inline-block;text-decoration:none;height:20px;line-height:20px;">
                <img src="../../static/admin/images/beian.png" style="float:left;"/>
                <p style="float:left;height:20px;line-height:20px;margin: 0px 0px 0px 5px; color:#939393;">鄂公网安备 42018502004474号</p>
            </a>
        </div>
    </div>
</div>
<script src="../../static/admin/layui_new/layui.all.js" type="text/javascript" charset="utf-8"></script>
<script type="text/javascript" src="../../static/admin/js/jquery-3.2.0.min.js"></script>
<script type="text/html" id="barDemo">
    <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看</a>
</script>
<script type="text/javascript">
	layui.use(['table','jquery'], function(){
		var table = layui.table;
        var $ = layui.jquery;
        var element = layui.element; //Tab的切换功能，切换事件监听等，需要依赖element模块
		//方法级渲染
		table.render({
			elem: '#LAY_table_user',
            url: '/web/admin/findListByDepartmentAndCollege',
            cols: [[
                {field:'id', title: 'ID',  sort: true, fixed: true},
                {field:'stname', title: '姓名',sort: true },
                {field:'stid', title: '学号',sort: true },
                {field:'gender', title: '性别', sort: true},
                {field:'age', title: '年龄', sort: true},
                {field:'department', title: '学校', sort: true},
                {field:'college', title: '专业', sort: true},
                {field:'province', title: '地址', sort: true},
                {field:'level', title: '抑郁程度', sort: true},
                {field:'stype', title: '学历', sort: true},
                {field:'year', title: '入学年份', sort: true},
                {fixed: 'right', align:'center',toolbar: '#barDemo'}
			]],
            id: 'testReload',
            page:false,
            method:'post',
            parseData:function (res) {
                var changeRes = res
                for(var i in res){
                    var stu = res[i]
                    if(stu.stype==2){
                        changeRes[i].stype = '博士'
                    }else if(stu.stype ==1){
                        changeRes[i].stype = '硕士'
                    }else if(stu.stype ==0){
                        changeRes[i].stype = '本科'
                    }
                }
                return {
                    "code":0,
                    "data":changeRes
                }
            }
		});
        //监听工具条
        table.on('tool(user)', function(obj){
            var data = obj.data;
            if(obj.event === 'detail'){
                console.log("点击")
                console.log(data.stid)
                window.open('persion.html?stid='+data.stid)

                // element.tabAdd('tab', {
                //     title: '学生王骞'
                //     ,content: '<iframe src="persion.html" width="100%" height="100%" name="iframe12" scrolling="auto" class="iframe" framborder="0" data-id="10"></iframe>'
                //     ,id: "editTab" //实际使用一般是规定好的id，这里以时间戳模拟下
                // });
            }
        });
		var active = {
			reload: function(){
				var demoReload = $('#demoReload');

				//执行重载
				table.reload('testReload', {
					page: {
						curr: 1 //重新从第 1 页开始
					}
					,where: {
						key: {
							id: demoReload.val()
						}
					}
				}, 'data');
			}
		};

		$('.demoTable .layui-btn').on('click', function(){
			var type = $(this).data('type');
            console.log(type)
            console.log('type')
			active[type] ? active[type].call(this) : '';
		});

	});
</script>
</body>
</html>
